package com.spa.infrastructure.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.spa.application.command.member.MassagistEvaluateAddCommand;
import com.spa.application.dto.PageResult;
import com.spa.application.dto.member.MemberEvaluateDTO;
import com.spa.application.dto.member.MemberMassagistEvaluateDTO;
import com.spa.application.dto.shop.ShopMassagistEvaluateDTO;
import com.spa.application.query.member.MemberMassagistEvaluateQuery;
import com.spa.domain.entity.MassagistEvaluate;
import com.spa.infrastructure.enums.dict.evaluate.SatisfactionStatusEnum;
import com.spa.infrastructure.repository.condition.MassagistEvaluateCondition;
import com.spa.infrastructure.repository.po.MassagistEvaluatePO;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
@MapperConfig(unmappedTargetPolicy = ReportingPolicy.WARN)
public interface MassagistEvaluateMapperStruct {

    MassagistEvaluateMapperStruct INSTANCE = Mappers.getMapper(MassagistEvaluateMapperStruct.class);

    @Mapping(source = "satisfaction", target = "isSatisfaction")
    @Mapping(source = "explain", target = "explainInfo")
    MassagistEvaluatePO commandMember2Po(MassagistEvaluateAddCommand command);

    Page<MassagistEvaluate> po2Entity4Page(Page<MassagistEvaluatePO> po);

    List<MassagistEvaluate> po2Entity4List(List<MassagistEvaluatePO> po);

    PageResult<MemberMassagistEvaluateDTO> entity2Dto4Page(Page<MassagistEvaluate> entity);


    @Mapping(source = "satisfaction", target = "satisfaction", qualifiedByName = "int2Enum")
    MemberMassagistEvaluateDTO entity2Dto(MassagistEvaluate entity);


    @Mapping(source = "isSatisfaction", target = "satisfaction")
//    @Mapping(source = "explainInfo", target = "explain")
    MassagistEvaluate po2Entity(MassagistEvaluatePO po);

    MassagistEvaluateCondition queryMember2Condition(MemberMassagistEvaluateQuery query);

    @Named("int2Enum")
    default SatisfactionStatusEnum int2Enum(int status) {
        return SatisfactionStatusEnum.byCode(status);
    }

    List<MemberEvaluateDTO> entity2Dto4List(List<MassagistEvaluate> entity);



    //========门店端===== start ↓ ===========
    PageResult<ShopMassagistEvaluateDTO> entity2ShopDto4Page(Page<MassagistEvaluate> entity);

    @Mapping(source = "satisfaction", target = "satisfaction", qualifiedByName = "int2Enum")
    @Mapping(source = "explainInfo", target = "explain")
    ShopMassagistEvaluateDTO entity2ShopDto(MassagistEvaluate entity);

    //========门店端===== end ↑ ===========


}
